package funnytrails;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.request.IRequestHandler;

public class ExampleFrame extends WebComponent
{
    /** */
    private static final long serialVersionUID = 1L;

    private CharSequence url;

    /**
     * @param id
     */
    public ExampleFrame(String id)
    {
        super(id);
    }

    /**
     * @param id
     * @param requestHandler
     */
    public ExampleFrame(String id, IRequestHandler requestHandler)
    {
        super(id);
        url = urlFor(requestHandler);
    }

    /**
     * @param id
     * @param url
     */
    public ExampleFrame(String id, CharSequence url)
    {
        super(id);
        this.url = url;
    }

    /**
     * Handles this frame's tag.
     * 
     * @param tag
     *            the component tag
     * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
     */
    @Override
    protected final void onComponentTag(final ComponentTag tag)
    {
        checkComponentTag(tag, "frame");

        tag.put("src", getUrl());

        super.onComponentTag(tag);
    }

    /**
     * @return src URL
     */
    protected CharSequence getUrl()
    {
        return url;
    }

}